<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--[if lt IE 7 ]> <html class="no-js ie6"> <![endif]-->
<!--[if IE 7 ]>    <html class="no-js ie7"> <![endif]-->
<!--[if IE 8 ]>    <html class="no-js ie8"> <![endif]-->
<!--[if IE 9 ]>    <html class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!-->
<html class="no-js">
<!--<![endif]-->
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <title>体检预约服务平台 - 医通在线</title>
    <link href="templates/css/global.css" rel="stylesheet" type="text/css" />
    <link href="templates/css/agency.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="templates/js/jquery-1.7.2.min.js"></script>
    <script src="templates/js/form.js" type="text/javascript"></script>
    <script src="templates/js/common.js" type="text/javascript"></script>
    <script src="templates/js/append.js" type="text/javascript"></script>
    <script src="templates/js/jx.js" type="text/javascript"></script>
    <meta content="" name="Keywords">
    <meta name="description" content="" />
    <!--[if IE 6]>
    <script src="../../js/ddpng.js" type="text/javascript"></script>
    <script type="text/javascript">DD_belatedPNG.fix('.ddpng');</script>
    <![endif]-->
    <script type="text/javascript">
        var userInfo = <{$userInfo1}>;
    </script>

</head>

<script type="text/javascript">

    function sub_form2(){
        var c= '';
        var s='';
        $('input[name^=pd_sa]:checked').each(function(i){
            c += i;
            s += "|"+$(this).val();
        });

        if(c==''){
            alert("请您勾选需要对比的套餐");
            return false;
        }

        if(c>=124){
            alert("最多只能选择四个套餐进行对比"+c);
            return false;
        }
        window.open("/index.php?action=compare&pid2="+s);
    }
</script>
<body>
<!--header st-->
<{include file="../templates/$newtpl/header.html"}>

<FORM style="margin-top:5px" action="/index.php?action=reservation_3"  method="post" enctype="application/x-www-form-urlencoded" name="appendform" target="_self" id="appendform">

<div class="row mb10 center_layout fix">
    <{include file="../templates/$newtpl/left.html"}>
    <div class="grid0 grid770">
        <div class="main_con">
            <div class="subline">
                <h4>预约登记</h4>
                <!-- 
                    <a href="<{$__URL__}>help" target="_blank" class="yuyue"><s></s>预约须知</a>
                -->
            </div>

            <div class="step">
                <img src="templates/images/step_2.png" />
            </div>

            <div class="con info_box info_make">
                <div class="info_table mb10">
                    <div class="con">
                        <div class="form">
                            <{if $project_add.info_tbts_qtkj!=''}>
                                <h6 class="mb20">特别提示</h6>
                                <p class="tip_box1">
                                    <{$project_add.info_tbts_qtkj}>
                                    <br>
                                    <{$project_add.info_tbts_qtkj_bold}>
                                </p>
                            <{/if}>

                            <h6 class="mb20">预约日期及门店</h6>

                            <dl style="padding:0">
                                <dd class="fix">
                                    <label class="text span1">
                                        1.&nbsp;使用城市：
                                    </label>
                                    <select name="city" class="span1" id="city" >
                                        <option value="">请选择城市</option>
                                        <{foreach from=$city_list key=key item=item name=citys}>
                                            <option value="<{$key}>"><{$item}></option>
                                        <{/foreach}>
                                    </select>
                                    <font color="#FF0000" style="font-size: 12px;">*（必填）</font>
                                </dd>

                                <dd class="fix">
                                    <label class="text span1">2.&nbsp;选择门店：</label>
                                    <table class="md_table" id="ses">
                                        <thead>
                                            <tr>
                                                <th width=100>机构</th>
                                                <th width=200>门店</th>
                                                <th width=230>门店地址</th>
                                                <th width=50>选择</th>
                                            </tr>
                                        </thead>
                                        <!-- ajax 加载门店列表 -->
                                        <tbody id="store" name="store">
                                        </tbody>
                                    </table>
                                </dd>

                                <dd class="fix">
                                        <label class="text span1">3.&nbsp;选择套餐：</label>
                                    <table class="md_table" id="pses">
                                        <thead>
                                            <tr>
                                                <!--
                                                      <th width=50>对比</th>
                                                  -->

                                                <th width=250>套餐名</th>
                                                <th width=80>市场价</th>
                                                <th width=80>员工价</th>
                                                <th width=100>您需支付的费用</th>
                                                <th width=100>套餐/门店</th>
                                                <th width=50>选择</th>
                                            </tr>
                                        </thead>

                                        <tbody id="product" name="product">
                                        </tbody>
                                    </table>
                                    <!-- 如果性别是女性 -->
                                    <{if $sex == 2 }>
                                        <div id="dis_show" style="float:left;display:none; margin-left: 119px;">
                                            <span style="color:red">女性已婚套餐比女性未婚套餐多了妇科相关的检查项目。</span>
                                        </div>
                                    <{/if}>

                                    <!--
                                        <div id="dis_show" style="float:left;display:none; margin-left: 119px;font-size: 12px;"><input type="button" name="url2"  id="url2" onclick="sub_form2();" value="套餐对比" />
                                            &nbsp;勾选套餐，点对比按钮查看套餐内容差异
                                        </div>
                                    -->
                                </dd>
                                
                                <dd class="fix" id="addon_area">
                                    <label class="text span1">套餐加项(可选)：</label>
                                    <table class="md_table">
                                        <thead>
                                            <tr>
                                                <th width=240>加项名称</th>
                                                <th width=120>查看详情</th>
                                                <th width=100>员工价</th>
                                                <th width=50>选择</th>
                                            </tr>
                                        </thead>
                                        
                                        <tbody id=jx name="jx">
                                        </tbody>
                                    </table>
                                </dd>
                                <!-- 检测是否有加项订单 -->
                                <{if !empty($soAddon) }>
                                    <dd class="fix"><label class="text span1">套餐已含加项：</label>
                                        <table class="md_table">
                                            <thead>
                                                <tr>
                                                    <th>
                                                        <{foreach from=$soAddon key=key item=item }>
                                                            <{$item}>&nbsp;&nbsp;&nbsp;
                                                        <{/foreach}>
                                                    </th>
                                                </tr>
                                            </thead>
                                        </table>
                                    </dd>
                                <{/if}>

                                <dd class="fix">
                                    <label class="text span1">4.&nbsp;预约时间：</label>
                                    <div class="choose">
                                        <input name="yytime" type="text" id="yytime" readonly="" />
                                        <font color="#FF0000" style="font-size: 12px;">*（必填）</font>
                                    </div>

                                    <cite class="red" id="ldtime" name="ldtime"></cite>
                                </dd>
                                <div id="freeset" name="freeset" ></div>
                            </dl>

                            <dl style="padding:0">
                                <dd class="fix">
                                    <label class="text span1">体检报告：</label>
                                    <cite><{$report_type_msg|replace:"400-820-6772":"400-820-6772-1-3"}></cite>
                                </dd>
                            </dl>
                            <!--
                                <dl style="padding:0;" id="ygdiv">
                                    <dd class="fix">
                                        <label class="text span1">乙肝报告：</label>
                                        <cite style="width: 435px;" id="ygbg">无</cite>
                                    </dd>
                                </dl>
                            -->
                             <dl>
                            <!--
                                <dd class="fix">
                                    <label class="text span1">寄送地址：</label>
                                    <select class="span1">
                                        <option>上海</option>
                                    </select>

                                    <select class="span1">
                                        <option>上海</option>
                                    </select>

                                    <select class="span1">
                                        <option>上海</option>
                                    </select>
                                </dd>
                                
                                <dd class="fix">
                                    <label class="text span1">&nbsp;</label>
                                    <input type="text" class="text" style="width:395px;height:20px;line-height:20px" placeholder="请输入详细地址" />
                                </dd>
                            </dl>
                            -->
                        </div>
                    </div>
                </div>
                <div class="btn">
                    <a href="javascript:void(0);"  title="提交预约" class="btn_fin" id='btn_submit_append'></a>
                    <input name="orderid" type="hidden" id="orderid" value="<{$orderid}>" />
                    <input name="birthday" type="hidden" id="birthday" value="<{$birthday}>" />
                    <input name="wedding" type="hidden" id="wedding" value="<{$wedding}>" />
                    <input name="email" type="hidden" id="email" value="<{$email}>" />
                    <input name="projectcode" type="hidden" id="projectcode" value="<{$project_code}>" />
                    <input name="wide" type="hidden" id="wide" value="<{$userinfo.user_wide}>" />
                    <input name="sex" type="hidden" id="sex" value="<{$userinfo.user_sex}>" />
                    <input name="tel" type="hidden" id="tel" value="<{$tel}>" />
                </div>
            </div>
        </div>
    </div>
</div>

<{include file="../templates/$newtpl/foot.html"}>
</FORM>
<!--脚本如下-->
<script src="templates/js/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="templates/js/jquery.switchable2.min.js" type="text/javascript"></script>
<script src="templates/js/cal.js" type="text/javascript"></script>
<script src="templates/js/global.js" type="text/javascript"></script>

<script type="text/javascript">

    jQuery(document).ready(function($) {

        /**
         * 选择档期
         */
        $('.choose').click(function() {
            get_free_time();
        });


        /**
         * 选择城市触发事件
         */
        $('#city').change(function() {
            //var browser=navigator.appName;
            //var b_version=navigator.appVersion;
            //var version=b_version.split(";");
            //var trim_Version=version[1].replace(/[ ]/g,"");

            var orderid = $('#orderid').val();
            var cityid = $('#city').val();
            var project_code = $('#projectcode').val();
            var productcode = '';

            var htmlStr = '';

            $("#loading").remove();
            $("#ses").append('<div id="loading" style="text-align:center; "><img src="templates/images/loading_1.gif"></div>');
            $("#store").empty();
            $("#product").empty();
            $("#jx").empty();
            $("#yytime").val('');

            $.getJSON("/index.php?action=deliver_store_dj&orderid=" + orderid+"&cityid=" + cityid+"&project_code=" + project_code+"&productcode=" + productcode , function(result) {

                if (result == null) {
                    $("#store").append("暂无门店数据");
                } else {
                    $.each(result, function(k, v) {
                        htmlStr  = "<tr style='font-size:12px'>" + v[0] + "</td>";
                        htmlStr += "<td><input type='radio' class='radiobtnfix' name='selectstore'  id='selectstore' value='" + v[1] +  "' onclick=storeNotice("+v[1]+");getProductList();get_store_ldtime(); /></td></tr>";
                        $("#store").append(htmlStr);
                    });
                }

                $("#loading").remove();
            });
        });


        /**
         * 提交预约
         */
        $('#btn_submit_append').click(function() {

            var city = $('#city').val();
            var store = $('input[name="selectstore"]:checked').val();
            var projectcode = $('#projectcode').val();
            var product =  $('input[name="selectproduct"]:checked').val();
            var yytime = $('#yytime').val();

            if(city == ''){
                alert('请选择城市');
                return false;
            }else if(typeof(store) == 'undefined'){
                alert('请选择一家门店');
                return false;
            }else if(projectcode == '' ){
                alert('非法的项目编码');
                return false;
            }else if(typeof(product) == 'undefined' ){
                alert('请选择您所需要的套餐');
                return false;
            }else if(yytime == '' ){
                alert('请输入预约时间');
                return false;
            }

            $("#appendform").submit();
        });
    });
    
    

    /**
     * 获取门店列表
     */
    function getProductList() {
        var store = $('input[name="selectstore"]:checked').val();
        var project_code = $('#projectcode').val();
        var wide = $('#wide').val();
        var orderid = $('#orderid').val();
        var wedding = $('#wedding').val();
        var sex = $('#sex').val();

        var getUrl = '';
        $("#product").empty();
        $("#jx").empty();
        $("#yytime").val('');
        $("#loading").remove();
        $("#pses").append('<div id="loading" style="text-align:center; "><img src="templates/images/loading_1.gif"></div>');

        getUrl = "/index.php?action=deliver_product_dj&store="+store+"&project_code=" + project_code+"&wide=" + wide+"&orderid=" + orderid+"&wedding=" + wedding+"&sex="+sex;
        
        $.getJSON( getUrl, function(result) {

            if (result == '') {
                $("#product").append("<tr ><td colspan=7>暂无套餐数据</td></tr>");
                $("#no_sa").val('1');
            } else {
                $.each(result, function(k, v) {
                    $("#product").append("<tr style='font-size:12px'><td><div align=left>" + v + "</div><td><input type='radio' class='radiobtnfix' onclick=getItemAddon();check_info("+store+",'"+k+"'); name='selectproduct'  id='selectproduct' value='" + k+  "' /></td></tr>");
                    $("#no_sa").val('0');
                });
            }

            $("#loading").remove();
        });
    }


    /**
     * 检测门店是否有特殊提示信息
     * 
     * @param  int      storeId     门店id
     */
    function storeNotice(storeId){

        //发送get请求数据
        var getData = {};

        //发送请求地址
        var url = '/index.php?action=get_store_notice';

        var projectCode = "<{$project_code}>";

        var notice = '';

        //检测门店Id是否合法
        if( storeId == '' || typeof(storeId) == 'undefined' ) {
            return false;
        }

        //检测套餐编码是否合法
        // if(productCode == '' || typeof(productCode) == 'undefined' ) {
        //  return false;
        // }

        getData = {
            //门店id
            store_id:storeId,

            //项目编码
            project_code:projectCode,

            //产品编码
            product_code : ''
        }

        //console.log('门店id:' + storeId + ' ; 套餐编码 : '+ productCode + ' ; 项目编码 : ' + projectCode);

        /**
         * 发送get Ajax 请求
         */
        $.getJSON( url , getData , function(data) {
            if( data.status == 1 ) {
                notice = '温馨提示：\n';
                notice +='      '+data.content;
                alert(notice);
            }
        });
    }


    /**
     * 获取加项信息
     * @return {[type]} [description]
     */
    function getItemAddon() {

        var is_notic = "该门店不支持此加项";
        var selectproduct = $('input[name="selectproduct"]:checked').val();
        var store_id = $('input[name="selectstore"]:checked').val();
        var orderid = $('#orderid').val();
        var diy_price = 0;

        var isShowAddonArea = userInfo.user_balance;

        if(selectproduct ==''){
            alert('请选择套餐');
            return false;
        }


        $.getJSON("/index.php?action=getitem&product="+selectproduct+"&store_id="+store_id+"&orderid="+orderid+"&time="+new Date().getTime(), function(result) {
            $("#jx").empty();

            if (result == null) {
                //$("#jx").append("暂无加项数据");
                $("#jx").append("<tr ><td colspan=4>无加项</td></tr>");
            } else {
                var jx_name ='';

                $.each(result, function(k, v) {
                    if(v[4] !='' && v[4] != null){
                        jx_name +=' '+v[0];
                        $("#jx").append("<tr style='font-size:12px' ><td><div align=center><a target='_blank' style='margin-left:75px;' href=./index.php?action=product_jx&jxcode="+v[5]+">"+v[0]+"</a></div></td><td><div align=center><a target='_blank' style='margin-left:38px;color:#0e6fa7' href=./index.php?action=product_jx&jxcode="+v[5]+">点击查看</a></div></td><td>￥"+v[1]+"</td><td><span>"+is_notic+"</span><input class='jx_item_select' disabled=disabled style='display:none;' type='checkbox' name='checkbox_value[]' value="+k+" /></td></tr>");
                    } else {
                        $("#jx").append("<tr style='font-size:12px' ><td><div align=center><a target='_blank' style='margin-left:75px;' href=./index.php?action=product_jx&jxcode="+v[5]+">"+v[0]+"</a></div></td><td><div align=center><a target='_blank' style='margin-left:38px;color:#0e6fa7' href=./index.php?action=product_jx&jxcode="+v[5]+">点击查看</a></div></td><td>￥"+v[1]+"</td><td><input class='jx_item_select' type='checkbox' name='checkbox_value[]' value="+k+" /></td></tr>");
                    }
                });

                if(jx_name!=''){
                    //alert("抱歉，该门店不支持 '"+jx_name+"' 加项,请更换其他门店");
                }
            }
        });
    }
</script>

</body>
</html>